DOORS Table Columns

Hi All,

I am trying to write a simple utility to aid update of DOORS tables. I need to loop through all the visible rows within a selected column and set an attribute for each cell in the column. As usual the dxl ref manual is not providing much help. Is there a "for rows in column construct that I can use?

Thanks

Mark


mwilliamson - Thu May 29 18:05:00 EDT 2014

Re: DOORS Table Columns
PRM - Thu May 29 20:57:57 EDT 2014

There is not a "for rows in column" loop available in the DXL library so you will need to simulate using the available "for row in table" and "for cell in row" loops but using a conditional statement to detect cells that are in a specific column.

The code snippet below uses these loops to display a row-column index for each cell, but it has a condition to focus on a specific column ("colOfInterest") where you would insert your specific actions for the cells of that column. The code snippet assumes that at least one cell in a DOORS table is currently selected.

 

Object tableRow
Object tableCell
int rowref=0
int colref=0
int colOfInterest = 2
 
for tableRow in table current Object do { //For each row in a table
    rowref++
    colref=0 
    for tableCell in row tableRow do { //For each cell in a row
        colref++
 if (colref == colOfInterest) print "[r" rowref""  "c" colref"]"  "\t"
 else print "r" rowref""  "c" colref""  "\t"
    }
    print "\n"
}

Re: DOORS Table Columns
Tony_Goodman - Fri May 30 04:17:17 EDT 2014

PRM - Thu May 29 20:57:57 EDT 2014

There is not a "for rows in column" loop available in the DXL library so you will need to simulate using the available "for row in table" and "for cell in row" loops but using a conditional statement to detect cells that are in a specific column.

The code snippet below uses these loops to display a row-column index for each cell, but it has a condition to focus on a specific column ("colOfInterest") where you would insert your specific actions for the cells of that column. The code snippet assumes that at least one cell in a DOORS table is currently selected.

 

Object tableRow
Object tableCell
int rowref=0
int colref=0
int colOfInterest = 2
 
for tableRow in table current Object do { //For each row in a table
    rowref++
    colref=0 
    for tableCell in row tableRow do { //For each cell in a row
        colref++
 if (colref == colOfInterest) print "[r" rowref""  "c" colref"]"  "\t"
 else print "r" rowref""  "c" colref""  "\t"
    }
    print "\n"
}

This example has a dialog and uses the currently selected cell to determine the column.

Add your code in where it says // do something...

void doApply(DB db)
{
 if (null current Module) return
 
 Object cellObject = current Object
 Object rowObject = null
 Object tableObject = null
 Object o = null
 int columnNumber = 0
 int col = 0
 
 if (null cellObject || !cell(cellObject)) return
 
 rowObject = getRow(cellObject)
 
 for o in row(rowObject) do
 {
  col++
  if (o == cellObject)
  {
   columnNumber = col
   break
  }
 }

 tableObject = getTable(cellObject)
 
 for rowObject in table(tableObject) do
 {
  col = 0
  
  for cellObject in row(rowObject) do
  {
   col++
   
   if (col == columnNumber)
   {
    // do something...

    break
   }
  }
 }
 
 refresh(current Module)
}

DB dbMain = create(dbExplorer, "Table Column", styleFloating)

DBE dbeGo = apply(dbMain, "Table Column", doApply)

realize(dbMain)

show(dbMain)

 Sorry about the formatting - couldn't get the code thing to work. IE problem I think.

 Tony

Re: DOORS Table Columns
mwilliamson - Fri May 30 04:38:20 EDT 2014

PRM - Thu May 29 20:57:57 EDT 2014

There is not a "for rows in column" loop available in the DXL library so you will need to simulate using the available "for row in table" and "for cell in row" loops but using a conditional statement to detect cells that are in a specific column.

The code snippet below uses these loops to display a row-column index for each cell, but it has a condition to focus on a specific column ("colOfInterest") where you would insert your specific actions for the cells of that column. The code snippet assumes that at least one cell in a DOORS table is currently selected.

 

Object tableRow
Object tableCell
int rowref=0
int colref=0
int colOfInterest = 2
 
for tableRow in table current Object do { //For each row in a table
    rowref++
    colref=0 
    for tableCell in row tableRow do { //For each cell in a row
        colref++
 if (colref == colOfInterest) print "[r" rowref""  "c" colref"]"  "\t"
 else print "r" rowref""  "c" colref""  "\t"
    }
    print "\n"
}

Hi Paul,

 

Many thanks, you are a saviour. As usual I was pretty close and have amended the script to update a specific tablecell attribute.

 

Thanks

 

Mark